package com.huawen.cms.app.controller;


import com.huawen.cms.app.service.UserInfoService;
import com.huawen.cms.app.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


public class BaseController {

    @Autowired
    HttpServletRequest request; //这里可以获取到request

    Pager getCurrentPager() {
        Pager pager = new Pager();

        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");

        if (pageNum == null || pageNum.equals("")) {
            pageNum = "1";
        }

        if (pageSize == null || pageSize.equals("")) {
            pageSize = "20";
        }

        pager.setPageNum(Integer.parseInt(pageNum));
        pager.setPageSize(Integer.parseInt(pageSize));

        return pager;
    }


}
